home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 2.1 KB | 70 lines | [TEXT/ToyS] |
- property kdtYearLong : 1 -- 1904-2020
-
- property kasTimeToSwitchOn : "0300" -- The time to switch on in 24 hour time
- property kasTimeToSwitchOff : "0200" -- The time to switch off in 24 hour time
-
- property kasDaylightOnEur : {-1, 1, 3, 0} -- Last Sunday in March (Europe)
- property kasDaylightOnUSA : {1, 1, 4, 0} -- First Sunday in April (USA)
- property kasDaylightOff : {-1, 1, 10, 0} -- Last Sunday in October (USA, Europe?)
-
-
- on run
- CheckDayLight()
- end run
-
-
- on idle
- CheckDayLight()
- return 60 -- Check every minute?
- end idle
-
-
- on CheckDayLight()
- -- Get current year
- set thisYear to (the clock using format kdtYearLong) as number
-
- -- Set year in our nth records (are we in Europe?)
- set greenwich to (time to GMT)
-
- -- Someone reported that this osax returned hours?!? Mine rerturns seconds
- if (greenwich < -24) or (greenwich > 24) then ¬
- set greenwich to greenwich / 3600 -- In hours
-
- -- Are we outside the USA?
- if (greenwich < -10) or (greenwich > -5) then
- set dstOn to kasDaylightOnEur
- else
- set dstOn to kasDaylighOnUSA
- end if
-
- -- I'm not sure of Europe's off time
- set dstOff to kasDaylightOff
-
- -- Insert current year
- set item 4 of dstOn to thisYear
- set item 4 of dstOff to thisYear
-
- -- Get dates for this year
- set thisYearOn to (the clock in sortable form using nth dstOn)
- set thisYearOff to (the clock in sortable form using nth dstOff)
- set thisYearNow to (the clock in extended sortable form)
-
- -- Add our setting hour to the On/Off dates
- set thisYearOn to thisYearOn & "." & kasTimeToSwitchOn
- set thisYearOff to thisYearOff & "." & kasTimeToSwitchOff
-
- -- Get current DST setting
- set ourLoc to (adjust the clock)
- set isOn to (daylight savings of ourLoc)
- set shouldBeOn to (thisYearNow ≥ thisYearOn) and (thisYearNow < thisYearOff)
-
- -- Need to switch?
- if (shouldBeOn is not isOn) then
- set daylight savings of ourLoc to shouldBeOn
- adjust the clock at geoposition ourLoc
- display dialog ("Daylight savings time adjustment has been performed for you.") ¬
- with icon note buttons {"Thank you, Akua!"} default button 1 ¬
- giving up after 300 -- Only MacOS 8.51 or later
- end if
- end CheckDayLight
-